<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:thSys="">
<div th:replace="admin/module/macros :: head('后台首页')"></div>
<body class="app sidebar-mini rtl">
<main class="app-content">
    <div th:replace="admin/module/macros :: header"></div>
    <div th:replace="admin/module/macros :: sidebar"></div>
    <div class="app-title">
        <div>
            <h1><i class="fa fa-dashboard"></i> 仪表盘</h1>
            <p>欢迎使用mayday博客</p>
        </div>
        <ul class="app-breadcrumb breadcrumb">
            <li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
            <li class="breadcrumb-item"><a href="#">仪表盘</a></li>
        </ul>
    </div>
    <div class="row">
        <div class="col-md-6 col-lg-3">
            <div class="widget-small primary coloured-icon"><i class="icon fa fa-book fa-3x"></i>
                <div class="info">
                    <h4>文章</h4>
                    <p><b th:text="${countPublish}"></b></p>
                </div>
            </div>
        </div>
        <div class="col-md-6 col-lg-3">
            <div class="widget-small info coloured-icon"><i class="icon fa fa-link fa-3x"></i>
                <div class="info">
                    <h4>友链</h4>
                    <p><b th:text="${countLinks}"></b></p>
                </div>
            </div>
        </div>
        <div class="col-md-6 col-lg-3">
            <div class="widget-small warning coloured-icon"><i class="icon fa fa-file-image-o fa-3x"></i>
                <div class="info">
                    <h4>媒体库</h4>
                    <p><b th:text="${countAttachment}"></b></p>
                </div>
            </div>
        </div>
        <div class="col-md-6 col-lg-3">
            <div class="widget-small danger coloured-icon"><i class="icon fa fa-star fa-3x"></i>
                <div class="info">
                    <h4>成立天数</h4>
                    <p><b th:text="${establishDate}"></b></p>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-6 col-md-12">
            <div class="tile">
                <h3 class="tile-title">最新文章</h3>
                <table class="table">
                    <tr>
                        <td>标题</td>
                        <td>状态</td>
                        <td>时间</td>
                    </tr>
                    <tr th:each="article : ${articles}">
                        <td><a th:text="${article.articleTitle}" target="_blank" th:title="${article.articleTitle}"
                               th:href="'/post/'+${article.articleUrl}"></a></td>
                        <td th:switch="${article.articleStatus}">
                            <th:block th:case="0">
                                <span class="badge badge-success">已发布</span>
                            </th:block>
                            <th:block th:case="1">
                                <span class="badge badge-info">草 稿</span>
                            </th:block>
                            <th:block th:case="2">
                                <span class="badge badge-danger">回收站</span>
                            </th:block>
                        </td>
                        <td th:text="${#dates.format(article.articleNewstime,'yyyy/MM/dd HH:mm:ss')}"></td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="col-lg-6 col-md-12">
            <div class="tile">
                <div>
                    <h3 class="tile-title" style="float: left;">最新日志</h3>
                    <div class="dropdown" style="float: right;">
                        <button type="button" class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown">
                            <i class="fa fa-bars"></i>
                        </button>
                        <div class="dropdown-menu">
                            <a class="dropdown-item" href="#" onclick="viewLogs()">查看所有</a>
                            <a class="dropdown-item" href="/admin/logs/clear">清空日志</a>
                        </div>
                    </div>
                </div>
                <table class="table">
                    <tr>
                        <td>事件</td>
                        <td>结果</td>
                        <td>IP</td>
                        <td>时间</td>
                    </tr>
                    <tr th:each="log : ${logs}">
                        <td th:text="${log.logTitle}"></td>
                        <td th:text="${log.logContent}"></td>
                        <td th:text="${log.logIp}"></td>
                        <td th:text="${#dates.format(log.logDate,'yyyy/MM/dd HH:mm:ss')}"></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="row">
    </div>
</main>
<div th:replace="admin/module/macros :: comm"></div>
<script type="text/javascript" src="/static/plugins/layer/layer.js"></script>
<script type="text/javascript">
    function viewLogs() {
        layer.open({
            type: 2,
            title: '所有日志',
            anim: 2,
            area: ['90%', '90%'],
            maxmin: true,
            content: "/admin/logs"
        });
    }
</script>
</body>
</html>